package com.topvision.myviewtest.viewpager;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.topvision.myviewtest.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author lucy
 * @date 2018-09-20 11:14
 * @description //TODO
 */

public class StateActivity extends AppCompatActivity {
    @BindView(R.id.tablayout)
    TabLayout mTabLayout;
    @BindView(R.id.viewpager)
    ViewPager mViewpager;

    private Fragment[] mFragments = {
            StateFragment.getInstance(10010),
            StateFragment.getInstance(10011),
            StateFragment.getInstance(10012),
            StateFragment.getInstance(10013),
    };

    private String[] mTitles = {
            "妹子",
            "帅哥",
            "猛男",
            "弱鸡",
    };

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_state_viewpager);
        ButterKnife.bind(this);
        initData();
    }

    private void initData() {
        mTabLayout.setupWithViewPager(mViewpager);
        StatePagerAdapter adapter = new StatePagerAdapter(getSupportFragmentManager(),mFragments,mTitles);
        mViewpager.setAdapter(adapter);
    }
}
